package com.liu.hooks;

import java.io.File;

import com.liu.util.TrackerLoger;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

public class FileHook extends AbstractHook {

	public static final String TAG = "#FileHook#";
	
	public static final String TYPE = "com.liu.hooks.FileHook";
	
	public XC_MethodHook fileHook = new XC_MethodHook() {
		
		@Override
		protected void afterHookedMethod(MethodHookParam param) throws Throwable {
			
			String path = (String) XposedHelpers.getObjectField(param.thisObject, "path");
			
			if(!path.contains("trackerlog")) {
				synchronized (this) {
					TrackerLoger.log(TAG, "[Path] " + path, TYPE, true);
				}
			}
			
		}
	};
	
	@Override
	public void doHook() {
		XposedBridge.hookAllConstructors(File.class, fileHook);
	}

	@Override
	public void setClassLoader(ClassLoader classloader) {
		this.classloader = classloader;
	}

}
